package com.hst.capacity.facade.rest;


import com.hst.capacity.application.biz.BrandBiz;
import com.hst.capacity.domain.model.request.SignInParam;
import com.hst.capacity.domain.model.request.brand.BrandUserParam;
import com.hst.capacity.domain.model.request.brand.BrandUserSearchParam;
import com.hst.capacity.domain.model.response.DefaultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static com.hst.capacity.domain.model.response.DefaultVO.success;

/**
 * 品牌商接口
 */
@RequestMapping("/brand")
@RestController
public class BrandController {

    @Autowired
    BrandBiz brandBiz;

    /**
     * 用户登录验证。登录成功，返回Token
     */
    @PostMapping("/user/sign-in")
    private DefaultVO signIn(@RequestBody @Valid SignInParam signInParam) {
        return success(brandBiz.signIn(signInParam));
    }

    /**
     * 创建用户
     *
     * @param param
     * @return
     */
    @PostMapping("/user/save")
    private DefaultVO userSave(@RequestBody @Valid BrandUserParam param) {
        return success(brandBiz.save(param));
    }

    /**
     * 编辑用户
     *
     * @param param
     * @return
     */
    @PostMapping("/user/list")
    private DefaultVO userList(@RequestBody @Valid BrandUserSearchParam param) {
        return success(brandBiz.search(param));
    }

}
